//
//  FFCollisionHandler.h
//  ForceField
//
//  Created by Roxanne Brittain on 11/22/11.
//  Copyright (c) 2011 Digifit. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FFObject.h"
#import "FFVector.h"
#include <vector>
#include <map>
#include <string>
#import <Foundation/Foundation.h>  
#import "FFFieldHandler.h"


#ifndef ForceField_FFCollisionHandler_h
#define ForceField_FFCollisionHandler_h

enum pairStatus {
    kNeedChecking = 0,
    kWillCollide = 1,
    kWontCollide = 2,
    kAreColliding = 3
    };

class FFCollisionHandler
{
public:
        
    void checkCollisions(std::vector<FFObject*> objects); //calls will collide on all object pairs that need checking
    BOOL objectOverlaps(std::vector<FFObject*> objects, FFObject *o);
    
    void handleCollision(FFObject *o1, FFObject *o2); //update object momentum

private:
    std::vector<FFObject*> collisionList;//a list of objects that are on a collision course
    std::map<std::string, pairStatus> pairStatusMap;
    
    bool willCollide(FFObject *o1, FFObject *o2); //called for every object with changed momentum. will these objects, w/ their current momentum, ever collide? if so mark the pair for needing check.
    bool areColliding(FFObject *o1, FFObject *o2); //are the circles themselves overlapping
};

std::string keyForObjectPair(FFObject *o1, FFObject *o2);


#endif
